import { useLocation, useRouteLoaderData } from "react-router-dom";

const Basic = () => {
    // 获取当前路由信息
    const $route = useLocation();
    console.log("$route", $route); // {"pathname":"/app/routeParams","search":"?id=123","hash":"","state":{"from":"basic"},"key":"cmv5t2wy"}

    // 获取路由加载器返回的数据 useRouteLoaderData(route-id)
    const data = useRouteLoaderData($route.pathname);
    console.log("data", data); // {"meta":{"title":"路由参数","icon":"SettingOutlined","requiresAuth":true}}

    return (
        <div>
            <div>route: {JSON.stringify($route)}</div>
            <div>data: {JSON.stringify(data)}</div>
        </div>
    );
};

export default Basic;
